package com.gxa.modules.app.hospital.health.controller;

import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Result;
import com.gxa.modules.app.hospital.health.service.HealthService01;
import com.gxa.modules.model.entity.hospital.Health;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

/**
 * <p>
 * 健康百科文章表 前端控制器
 * </p>
 *
 * @author lst
 * @since 2022-11-11
 */
@Api(tags = "健康百科")
@RestController
@Slf4j
@RequestMapping("/health")
public class HealthController01 {


    @Autowired
    private HealthService01 healthService01;

    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "totalCount",value ="总记录数",dataType ="int"),
            @ApiImplicitParam(paramType = "query",name = "pageSize",value ="每页显示多少条",dataType ="int",required = true),
//            @ApiImplicitParam(paramType = "query",name = "username",value ="查询条件",dataType ="String"),
            @ApiImplicitParam(paramType = "query",name = "totalPage",value ="总页数",dataType ="int"),
            @ApiImplicitParam(paramType = "query",name = "currPage",value ="当前是第几页",dataType ="int"),

    })
    @GetMapping
    public Result<PageUtils> queryByPage (@RequestParam @ApiIgnore Map<String,Object> params){
        log.info("健康百科收到的参数{}", params);
        PageUtils pageUtils = this.healthService01.queryByPage(params);
        return new Result<PageUtils>().ok(pageUtils);
    }


    @ApiOperation(value = "根据id查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value ="健康百科id",dataType ="int"),
    })
    @GetMapping("/query")
    public Result<Health> queryByPage (Integer id){
        Health health = healthService01.queryById(id);
        return new Result<Health>().ok(health);
    }

}
